import pymongo,easygui,time
from tqdm import tqdm
import random
 
myclient = pymongo.MongoClient("mongodb://localhost:27017/")
mydb = myclient["doubao"]
mycol = mydb["questions"]
de_fen=0
# mydict = { "name": "lisi", "age": 30, "adress": "内江" }
 
# x = mycol.insert_one(mydict) 


# for x in mycol.find():
  # print(x)
  
  
# myquery = { "name": "zhangsna" }
# newvalues = { "$set": { "age": 50 } }
 
# mycol.update_many(myquery, newvalues)

# print("======================")

# for x in mycol.find():
  # print(x)
  
  
# myquery = { "name": "lisi" }
 
# mycol.delete_many(myquery)
for j in tqdm(range(100)):
    if j<=20:
        time.sleep(random.randint(1,2))
    # print(j)
    else:
        time.sleep(0.01)

mydoc = mycol.find()
for x in mydoc:
    print(x['question'])
    print(x['options'])
    print(x['answer'])
    reply=easygui.buttonbox(x['question'],choices=x['options'])
    if reply==x['answer']:
        de_fen+=1
easygui.msgbox(f'您的得分为：{de_fen}分')

